
using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.Windows;
using System.Windows.Input;
using AdventureWorks.Client.Objects;
using AdventureWorks.Services;
using Xomega.Framework;

namespace AdventureWorks.Client.WPF
{
    public partial class EmployeeSearch
    {
        partial void PostInitialize()
        {
            gridResults.MouseDoubleClick += delegate { OpenDetails(); };
            btnDetails.Click += delegate { OpenDetails(); };
            btnNew.Click += delegate { CreateNew(); };
        }

        private void OpenDetails()
        {
            if (gridResults.SelectedIndex >= 0)
            {
                //[TODO: invoke the right details forms]
                list.CurrentRow = gridResults.SelectedIndex;
                EmployeeDetails.Invoke(this, -1, list.IdProperty.Value.Value);
            }
        }

        private void CreateNew()
        {
            //[TODO: invoke the right details forms]
            EmployeeDetails.Invoke(this);
        }
    }
}
